using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class hammer : MonoBehaviour
{
    public float damage = -5;
    public float repeatDuration = 2;
    private float delay=0;
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        if (delay < repeatDuration )
        {

            

            delay += Time.deltaTime;
        }
        else
        {
            gameObject.GetComponent<BoxCollider2D>().enabled = true;
            GetComponent<Animator>().Play(Animator.StringToHash("hammer"));
            delay = 0;
        }



    }
    public void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.tag == "Player")
        {

            collision.gameObject.GetComponent<playerControl>().hit(collision.gameObject, damage);
        }
    }
    public void closeCollider()
    {
        gameObject.GetComponent<BoxCollider2D>().enabled = false;
    }
}
